﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Collections;
using TS_XY_Train_Repaire.UserCon.Stuff;
namespace TS_XY_Train_Repaire.Stuff
{
    public partial class Stuff_Manage_ManaForm_ForDep : DevExpress.XtraEditors.XtraForm
    {
        public string _strQuery = "";
        public Stuff_Manage_ManaForm_ForDep()
        {
            InitializeComponent();
        }

        private void Stuff_Manage_ManaForm_ForDep_Load(object sender, EventArgs e)
        {
            _LoadOrgList();
        }

        private void Stuff_Manage_ManaForm_ForDep_FormClosing(object sender, FormClosingEventArgs e)
        {
            TS_Win_Locomotive_MainForm.htActionItem.Remove(this.Name);
        }
        #region//--组织结构--//
        private void _LoadOrgList()
        {
            gc_Main.DataSource = null;
            gc_Main.Refresh();
            LeverString_SysOrganization _ls = new LeverString_SysOrganization();
            tl_Main.Nodes.Clear();
            tl_Main.Refresh();
            ArrayList pList = new ArrayList();
            _ls = new LeverString_SysOrganization();
            _ls.f_id = "H";
            _ls.f_name = "部门结构";
            _ls.f_imgindex = 0;
            pList.Add(_ls);
            string strSQL = "select * from TS_S_T_P_Department where f_id="+TS_Win_Locomotive_MainForm.pUserInfoMain.UserDepTopID;
            SqlConnection conn = new SqlConnection(TS_Win_Class.GetSQlConnStr());
            conn.Open();
            SqlCommand cmd = new SqlCommand(strSQL, conn);
            SqlDataReader read = cmd.ExecuteReader();
            string _strDepQuery = " and (";
            int i = 0;
            while (read.Read())
            {
                if (i == 0)
                {
                    _strDepQuery += "(f_level like ',%"+read["f_id"].ToString()+"%,')";
                }
                else
                {
                    _strDepQuery += " or (f_level like ',%" + read["f_id"].ToString() + "%,')";
                }
                _ls = new LeverString_SysOrganization();
                _ls.f_id = "D" + read["f_id"].ToString();
                _ls.f_name = read["f_name"].ToString();
                _ls.f_code = read["f_code"].ToString();
                _ls.f_deep = read["f_deep"].ToString();
                _ls.f_level = read["f_level"].ToString();
                _ls.f_rbid = read["f_rbid"].ToString();
                _ls.f_rsid = read["f_rsid"].ToString();
                _ls.f_parent = "H";
                _ls.f_imgindex = 3;
                pList.Add(_ls);
                i++;
            }
             _strDepQuery+=")";
             read.Close();
             strSQL = "select * from TS_S_T_P_Department where f_deep>0 " + _strDepQuery + "  and f_del=0 order by f_id asc";
             cmd = new SqlCommand(strSQL, conn);
             read = cmd.ExecuteReader();
             while (read.Read())
             {
                 _ls = new LeverString_SysOrganization();
                 _ls.f_id = "D" + read["f_id"].ToString();
                 _ls.f_name = read["f_name"].ToString();
                 _ls.f_code = read["f_code"].ToString();
                 _ls.f_deep = read["f_deep"].ToString();
                 _ls.f_level = read["f_level"].ToString();
                 _ls.f_rbid = read["f_rbid"].ToString();
                 _ls.f_rsid = read["f_rsid"].ToString();
                 string _UPID = "";
                 _UPID = read["f_level"].ToString();
                 _UPID = _UPID.Substring(0, _UPID.Length - 1);
                 _UPID = _UPID.Substring(_UPID.LastIndexOf(',') + 1);
                 _ls.f_parent = "D" + _UPID;
                 _ls.f_imgindex = 3;
                 pList.Add(_ls);
             }
             read.Close();
             strSQL = "select f_id,(select f_name from TS_S_T_P_Position where f_id=TS_S_T_P_Dep_Position.f_posid)as f_name,(select f_code from TS_S_T_P_Position where f_id=TS_S_T_P_Dep_Position.f_posid)as f_code,f_depid,f_posid,(select f_rbid from TS_S_T_P_Department where f_id=TS_S_T_P_Dep_Position.f_depid) as f_rbid,(select f_rsid from TS_S_T_P_Department where f_id=TS_S_T_P_Dep_Position.f_depid) as f_rsid from TS_S_T_P_Dep_Position where f_del=0 and f_depid in (select f_id from TS_S_T_P_Department where f_del=0  and (f_level like '%," + TS_Win_Locomotive_MainForm.pUserInfoMain.UserDepTopID + ",%' or f_id=" + TS_Win_Locomotive_MainForm.pUserInfoMain.UserDepTopID + ")) and f_posid in (select f_id from TS_S_T_P_Position where f_del=0 ) order by f_id asc";
             cmd = new SqlCommand(strSQL, conn);
             read = cmd.ExecuteReader();
             while (read.Read())
             {
                 _ls = new LeverString_SysOrganization();
                 _ls.f_id = "P" + read["f_id"].ToString();
                 _ls.f_name = read["f_name"].ToString();
                 _ls.f_code = read["f_code"].ToString();
                 _ls.f_rbid = read["f_rbid"].ToString();
                 _ls.f_rsid = read["f_rsid"].ToString();
                 _ls.f_depid = read["f_depid"].ToString();
                 _ls.f_posid = read["f_posid"].ToString();
                 _ls.f_parent = "D" + read["f_depid"].ToString();
                 _ls.f_imgindex = 4;
                 pList.Add(_ls);
             }
             read.Close();
            conn.Close();
            conn.Dispose();

            tl_Main.DataSource = pList;
        }

        private void tl_Main_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            bbi_Stuff_Add.Tag = "";
            bbi_Dep_Sub_Add.Enabled=false;
            bbi_Dep_Edit.Enabled=false;
            bbi_Dep_Del.Enabled=false;
            bbi_Stuff_Add.Enabled=false;
            bbi_Stuff_Edit.Enabled=false;
            bbi_Stuff_Del.Enabled=false;
            try
            {
                if (tl_Main.FocusedNode["f_id"].ToString().Substring(0,1) == "H")
                {
                }
                if (tl_Main.FocusedNode["f_id"].ToString().Substring(0, 1) == "B")
                {
                }
                if (tl_Main.FocusedNode["f_id"].ToString().Substring(0, 1) == "S")
                {
                }
                if (tl_Main.FocusedNode["f_id"].ToString().Substring(0, 1) == "D")
                {
                    bbi_Dep_Sub_Add.Enabled = true;
                    bbi_Dep_Edit.Enabled = true;
                    bbi_Dep_Del.Enabled = true;
                }
                if (tl_Main.FocusedNode["f_id"].ToString().Substring(0, 1) == "P")
                {
                    bbi_Stuff_Add.Enabled = true;
                    bbi_Stuff_Add.Tag = "Blank";
                }
            }
            catch
            {
            }
        }
        #region//--路局管理--//

        private void bbi_RB_Add_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            uc_RailwayBureau_ManaForm _uc = new uc_RailwayBureau_ManaForm();
            _uc._LoadID = tl_Main.FocusedNode["f_id"].ToString();
            _uc._LoadName = tl_Main.FocusedNode["f_name"].ToString();
            _uc._LoadCode = tl_Main.FocusedNode["f_code"].ToString();
            _uc._LoadType = "Add";
            if (_uc.ShowDialog() == DialogResult.OK)
            {
                _LoadOrgList();
                tl_Main.SetFocusedNode(tl_Main.FindNodeByFieldValue("f_id", _uc._LoadID));
            }
            else
            {
            }
            _uc.Dispose();
        }

        private void bbi_RB_Edit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            uc_RailwayBureau_ManaForm _uc = new uc_RailwayBureau_ManaForm();
            _uc._LoadID = tl_Main.FocusedNode["f_id"].ToString();
            _uc._LoadName = tl_Main.FocusedNode["f_name"].ToString();
            _uc._LoadCode = tl_Main.FocusedNode["f_code"].ToString();
            _uc._LoadType = "Edit";
            if (_uc.ShowDialog() == DialogResult.OK)
            {
                _LoadOrgList();
                tl_Main.SetFocusedNode(tl_Main.FindNodeByFieldValue("f_id", _uc._LoadID));
            }
            else
            {
            }
            _uc.Dispose();
        }

        private void bbi_RB_Del_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string _UpID = "-1";
            try
            {
                _UpID = tl_Main.FocusedNode.PrevNode["f_id"].ToString();
            }
            catch
            { }
            uc_RailwayBureau_ManaForm _uc = new uc_RailwayBureau_ManaForm();
            _uc._LoadID = tl_Main.FocusedNode["f_id"].ToString();
            _uc._LoadName = tl_Main.FocusedNode["f_name"].ToString();
            _uc._LoadCode = tl_Main.FocusedNode["f_code"].ToString();
            _uc._LoadType = "Del";
            if (_uc.ShowDialog() == DialogResult.OK)
            {
                _LoadOrgList();
                tl_Main.SetFocusedNode(tl_Main.FindNodeByFieldValue("f_id", _UpID));
            }
            else
            {
            }
            _uc.Dispose();
        }
        #endregion
        #region//--站段管理--//
        private void bbi_RS_Add_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            uc_RailwayStation_ManaForm _uc = new uc_RailwayStation_ManaForm();
            _uc._LoadID = tl_Main.FocusedNode["f_id"].ToString();
            _uc._LoadRbid = tl_Main.FocusedNode["f_rbid"].ToString();
            _uc._LoadName = tl_Main.FocusedNode["f_name"].ToString();
            _uc._LoadCode = tl_Main.FocusedNode["f_code"].ToString();
            _uc._LoadType = "Add";
            if (_uc.ShowDialog() == DialogResult.OK)
            {
                _LoadOrgList();
                tl_Main.SetFocusedNode(tl_Main.FindNodeByFieldValue("f_id", _uc._LoadID));
            }
            else
            {
            }
            _uc.Dispose();
        }

        private void bbi_RS_Edit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            uc_RailwayStation_ManaForm _uc = new uc_RailwayStation_ManaForm();
            _uc._LoadID = tl_Main.FocusedNode["f_id"].ToString();
            _uc._LoadRbid = tl_Main.FocusedNode["f_rbid"].ToString();
            _uc._LoadName = tl_Main.FocusedNode["f_name"].ToString();
            _uc._LoadCode = tl_Main.FocusedNode["f_code"].ToString();
            _uc._LoadType = "Edit";
            if (_uc.ShowDialog() == DialogResult.OK)
            {
                _LoadOrgList();
                tl_Main.SetFocusedNode(tl_Main.FindNodeByFieldValue("f_id", _uc._LoadID));
            }
            else
            {
            }
            _uc.Dispose();
        }

        private void bbi_RS_Del_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string _UpID = "-1";
            try
            {
                _UpID = tl_Main.FocusedNode.PrevNode["f_id"].ToString();
            }
            catch
            { }
            uc_RailwayStation_ManaForm _uc = new uc_RailwayStation_ManaForm();
            _uc._LoadID = tl_Main.FocusedNode["f_id"].ToString();
            _uc._LoadRbid = tl_Main.FocusedNode["f_rbid"].ToString();
            _uc._LoadName = tl_Main.FocusedNode["f_name"].ToString();
            _uc._LoadCode = tl_Main.FocusedNode["f_code"].ToString();
            _uc._LoadType = "Del";
            if (_uc.ShowDialog() == DialogResult.OK)
            {
                _LoadOrgList();
                tl_Main.SetFocusedNode(tl_Main.FindNodeByFieldValue("f_id", _UpID));
            }
            else
            {
            }
            _uc.Dispose();
        }

        #endregion
        #region//--部门管理--//
        private void bbi_Dep_Add_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            uc_Stuff_Department_ManaForm _uc = new uc_Stuff_Department_ManaForm();
            _uc._LoadID = tl_Main.FocusedNode["f_id"].ToString();
            _uc._LoadRbid = tl_Main.FocusedNode["f_rbid"].ToString();
            _uc._LoadRsid = tl_Main.FocusedNode["f_rsid"].ToString();
            _uc._LoadDeep = tl_Main.FocusedNode["f_deep"].ToString();
            _uc._LoadLevel = tl_Main.FocusedNode["f_level"].ToString();
            _uc._LoadName = tl_Main.FocusedNode["f_name"].ToString();
            _uc._LoadCode = tl_Main.FocusedNode["f_code"].ToString();
            _uc._LoadType = "Add";
            if (_uc.ShowDialog() == DialogResult.OK)
            {
                _LoadOrgList();
                tl_Main.SetFocusedNode(tl_Main.FindNodeByFieldValue("f_id", _uc._LoadID));
            }
            else
            {
            }
            _uc.Dispose();
        }

        private void bbi_Dep_Sub_Add_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            uc_Stuff_Department_ManaForm _uc = new uc_Stuff_Department_ManaForm();
            _uc._LoadID = tl_Main.FocusedNode["f_id"].ToString();
            _uc._LoadRbid = tl_Main.FocusedNode["f_rbid"].ToString();
            _uc._LoadRsid = tl_Main.FocusedNode["f_rsid"].ToString();
            _uc._LoadDeep = tl_Main.FocusedNode["f_deep"].ToString();
            _uc._LoadLevel = tl_Main.FocusedNode["f_level"].ToString();
            _uc._LoadName = tl_Main.FocusedNode["f_name"].ToString();
            _uc._LoadCode = tl_Main.FocusedNode["f_code"].ToString();
            _uc._LoadType = "Sub_Add";
            if (_uc.ShowDialog() == DialogResult.OK)
            {
                _LoadOrgList();
                tl_Main.SetFocusedNode(tl_Main.FindNodeByFieldValue("f_id", _uc._LoadID));
            }
            else
            {
            }
            _uc.Dispose();
        }

        private void bbi_Dep_Edit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            uc_Stuff_Department_ManaForm _uc = new uc_Stuff_Department_ManaForm();
            _uc._LoadID = tl_Main.FocusedNode["f_id"].ToString();
            _uc._LoadRbid = tl_Main.FocusedNode["f_rbid"].ToString();
            _uc._LoadRsid = tl_Main.FocusedNode["f_rsid"].ToString();
            _uc._LoadDeep = tl_Main.FocusedNode["f_deep"].ToString();
            _uc._LoadLevel = tl_Main.FocusedNode["f_level"].ToString();
            _uc._LoadName = tl_Main.FocusedNode["f_name"].ToString();
            _uc._LoadCode = tl_Main.FocusedNode["f_code"].ToString();
            _uc._LoadType = "Edit";
            if (_uc.ShowDialog() == DialogResult.OK)
            {
                _LoadOrgList();
                tl_Main.SetFocusedNode(tl_Main.FindNodeByFieldValue("f_id", _uc._LoadID));
            }
            else
            {
            }
            _uc.Dispose();
        }

        private void bbi_Dep_Del_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string _UpID = "-1";
            try
            {
                _UpID = tl_Main.FocusedNode.PrevNode["f_id"].ToString();
            }
            catch
            { }
            uc_Stuff_Department_ManaForm _uc = new uc_Stuff_Department_ManaForm();
            _uc._LoadID = tl_Main.FocusedNode["f_id"].ToString();
            _uc._LoadRbid = tl_Main.FocusedNode["f_rbid"].ToString();
            _uc._LoadRsid = tl_Main.FocusedNode["f_rsid"].ToString();
            _uc._LoadDeep = tl_Main.FocusedNode["f_deep"].ToString();
            _uc._LoadLevel = tl_Main.FocusedNode["f_level"].ToString();
            _uc._LoadName = tl_Main.FocusedNode["f_name"].ToString();
            _uc._LoadCode = tl_Main.FocusedNode["f_code"].ToString();
            _uc._LoadType = "Del";
            if (_uc.ShowDialog() == DialogResult.OK)
            {
                _LoadOrgList();
                tl_Main.SetFocusedNode(tl_Main.FindNodeByFieldValue("f_id", _UpID));
            }
            else
            {
            }
            _uc.Dispose();
        }
        #endregion
        #region//--职务管理--//

        private void bbi_Pos_Mana_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string _str = "-1";
            try { _str = tl_Main.FocusedNode["f_id"].ToString(); }
            catch { }
            Stuff_Position_Manage_ManaForm _uc = new Stuff_Position_Manage_ManaForm();
            if (_uc.ShowDialog() == DialogResult.OK)
            {
                _LoadOrgList();
                tl_Main.SetFocusedNode(tl_Main.FindNodeByFieldValue("f_id",_str));
            }
        }

        private void bbi_Pos_Dep_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string _str = "-1";
            try { _str = tl_Main.FocusedNode["f_id"].ToString(); }
            catch { }
            uc_Department_Position_Relation_ManaForm _uc = new uc_Department_Position_Relation_ManaForm();
            _uc._LoadID = tl_Main.FocusedNode["f_id"].ToString();
            _uc._LoadName = tl_Main.FocusedNode["f_name"].ToString();
            if (_uc.ShowDialog() == DialogResult.OK)
            {
                _LoadOrgList();
                tl_Main.SetFocusedNode(tl_Main.FindNodeByFieldValue("f_id", _str));
            }
        }
        #endregion
        private void tl_Main_DoubleClick(object sender, EventArgs e)
        {
            if (tl_Main.FocusedNode["f_id"].ToString().Substring(0, 1) == "D")
            {
                _strQuery = " and f_depid in (select f_id from TS_S_T_P_Department where f_del=0 and (f_id=" + tl_Main.FocusedNode["f_id"].ToString().Substring(1) + " or f_level like '%," + tl_Main.FocusedNode["f_id"].ToString().Substring(1) + ",%'))";
                _LoadStuffList();
            }
            else if (tl_Main.FocusedNode["f_id"].ToString().Substring(0, 1) == "P")
            {
                _strQuery = " and (f_depid=" + tl_Main.FocusedNode["f_depid"].ToString() + " and f_posid=" + tl_Main.FocusedNode["f_posid"].ToString() + ")";
                _LoadStuffList();
            }
            else
            {
                gc_Main.DataSource = null;
                gc_Main.Refresh();
            }
        }
        #endregion

        private void bbi_Reload_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            _LoadOrgList();
        }

        #region//--人员管理--//
        private void _LoadStuffList()
        {
            string strSQL = "select row_number() over (order by f_id) as f_row,*,(select f_name from TS_S_T_P_Department where f_id=TS_S_T_P_Stuff.f_depid) as f_depname,(select f_name from TS_S_T_P_Position where f_id=TS_S_T_P_Stuff.f_posid) as f_posname,(select f_name from TS_S_T_P_CadreRank where f_id=TS_S_T_P_Stuff.f_gbid) as f_gbname,(select f_name from TS_S_T_P_ProfessionSkill where f_id=TS_S_T_P_Stuff.f_zyjsid) as f_zyjsname,(select f_name from TS_S_T_P_StationBiaoShi where f_id=TS_S_T_P_Stuff.f_gwid) as f_gwname,(select f_name from TS_S_T_P_PersonAttribute where f_id=TS_S_T_P_Stuff.f_rysxid) as f_rysxname from TS_S_T_P_Stuff  where f_del=0 " + _strQuery;
            DataTable dt = new DataTable();
            TS_Win_Class.FilledDataTable(strSQL, dt);
            gc_Main.DataSource = dt;
            bbi_Stuff_Edit.Enabled = false;
            bbi_Stuff_Del.Enabled = false;
        }
        private void bbi_Stuff_Add_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            uc_Stuff_Main_Info_ManaForm _uc = new uc_Stuff_Main_Info_ManaForm();
            _uc._LoadTag = bbi_Stuff_Add.Tag.ToString();
            if (bbi_Stuff_Add.Tag.ToString() == "Blank")
            {
                _uc._RBID = tl_Main.FocusedNode["f_rbid"].ToString();
                _uc._RSID = tl_Main.FocusedNode["f_rsid"].ToString();
                _uc._DepID = tl_Main.FocusedNode["f_depid"].ToString();
                _uc._LoadDepName = tl_Main.FocusedNode.ParentNode["f_name"].ToString();
                _uc._PosID = tl_Main.FocusedNode["f_posid"].ToString();
            }
            else
            {
                _uc._LoadID = gv_Main.GetRowCellValue(gv_Main.GetSelectedRows()[0], "f_id").ToString();
                _uc._RBID = gv_Main.GetRowCellValue(gv_Main.GetSelectedRows()[0], "f_rbid").ToString();
                _uc._RSID = gv_Main.GetRowCellValue(gv_Main.GetSelectedRows()[0], "f_rsid").ToString();
                _uc._DepID = gv_Main.GetRowCellValue(gv_Main.GetSelectedRows()[0], "f_depid").ToString();
                _uc._LoadDepName = gv_Main.GetRowCellValue(gv_Main.GetSelectedRows()[0], "f_depname").ToString();
                _uc._PosID = gv_Main.GetRowCellValue(gv_Main.GetSelectedRows()[0], "f_posid").ToString();
            }
            _uc._LoadType = "Add";

            if (_uc.ShowDialog() == DialogResult.OK)
            {
                _LoadStuffList();
            }
            else
            {
            }
        }

        private void bbi_Stuff_Edit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            uc_Stuff_Main_Info_ManaForm _uc = new uc_Stuff_Main_Info_ManaForm();
            _uc._LoadTag = bbi_Stuff_Add.Tag.ToString();
                _uc._LoadID = gv_Main.GetRowCellValue(gv_Main.GetSelectedRows()[0], "f_id").ToString();
                _uc._RBID = gv_Main.GetRowCellValue(gv_Main.GetSelectedRows()[0], "f_rbid").ToString();
                _uc._RSID = gv_Main.GetRowCellValue(gv_Main.GetSelectedRows()[0], "f_rsid").ToString();
                _uc._DepID = gv_Main.GetRowCellValue(gv_Main.GetSelectedRows()[0], "f_depid").ToString();
                _uc._LoadDepName = gv_Main.GetRowCellValue(gv_Main.GetSelectedRows()[0], "f_depname").ToString();
                _uc._PosID = gv_Main.GetRowCellValue(gv_Main.GetSelectedRows()[0], "f_posid").ToString();
            _uc._LoadType = "Edit";

            if (_uc.ShowDialog() == DialogResult.OK)
            {
                _LoadStuffList();
            }
            else
            {
            }
        }

        private void bbi_Stuff_Del_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            uc_Stuff_Main_Info_ManaForm _uc = new uc_Stuff_Main_Info_ManaForm();
            _uc._LoadTag = bbi_Stuff_Add.Tag.ToString();
            _uc._LoadID = gv_Main.GetRowCellValue(gv_Main.GetSelectedRows()[0], "f_id").ToString();
            _uc._RBID = gv_Main.GetRowCellValue(gv_Main.GetSelectedRows()[0], "f_rbid").ToString();
            _uc._RSID = gv_Main.GetRowCellValue(gv_Main.GetSelectedRows()[0], "f_rsid").ToString();
            _uc._DepID = gv_Main.GetRowCellValue(gv_Main.GetSelectedRows()[0], "f_depid").ToString();
            _uc._LoadDepName = gv_Main.GetRowCellValue(gv_Main.GetSelectedRows()[0], "f_depname").ToString();
            _uc._PosID = gv_Main.GetRowCellValue(gv_Main.GetSelectedRows()[0], "f_posid").ToString();
            _uc._LoadType = "Del";

            if (_uc.ShowDialog() == DialogResult.OK)
            {
                _LoadStuffList();
            }
            else
            {
            }
        }
        private void gc_Main_Click(object sender, EventArgs e)
        {
            if (gv_Main.SelectedRowsCount > 0)
            {
                bbi_Stuff_Add.Tag = "Info";
                bbi_Stuff_Add.Enabled = true;
                bbi_Stuff_Edit.Enabled = true;
                bbi_Stuff_Del.Enabled = true;
            }
            else
            {
                bbi_Stuff_Edit.Enabled = false;
                bbi_Stuff_Del.Enabled = false;
            }
        }

        private void gc_Main_DataSourceChanged(object sender, EventArgs e)
        {
            bbi_Stuff_Add.Enabled = false;
            bbi_Stuff_Edit.Enabled = false;
            bbi_Stuff_Del.Enabled = false;
        }
        #endregion

        #region//--人员属性--//
        private void bbi_Stuff_gb_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            uc_Stuff_GanBu_ManaForm _uc = new uc_Stuff_GanBu_ManaForm();
            _uc.ShowDialog();
        }

        private void bbi_Stuff_zyjs_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            uc_Stuff_ZhuanYeJiShu_ManaForm _uc = new uc_Stuff_ZhuanYeJiShu_ManaForm();
            _uc.ShowDialog();
        }

        private void bbi_Stuff_gw_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            uc_Stuff_GangWei_ManaForm _uc = new uc_Stuff_GangWei_ManaForm();
            _uc.ShowDialog();
        }

        private void bbi_Stuff_rysx_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            uc_Stuff_GouCheng_ManaForm _uc = new uc_Stuff_GouCheng_ManaForm();
            _uc.ShowDialog();
        }
        #endregion

        private void bt_Query_Click(object sender, EventArgs e)
        {
            if (tb_Query.Text.Trim().Length == 0)
            {
                _strQuery = "";
            }
            else
            {
                _strQuery = " and (f_workercode like '%" + tb_Query.Text.Trim() + "%' or f_jp like '%" + tb_Query.Text.Trim().ToUpper() + "%' or f_name like '%" + tb_Query.Text.Trim() + "%') and f_depid in (select f_id from TS_S_T_P_Department where f_del=0 and (f_level like '%,"+TS_Win_Locomotive_MainForm.pUserInfoMain.UserDepTopID+ ",%' or f_id=" + TS_Win_Locomotive_MainForm.pUserInfoMain.UserDepTopID + "))";
                _LoadStuffList();
            }
        }

    }
}